class PaceConverter
  def initialize(meters = 0, seconds = 1)
    @seconds = seconds.to_i
    @distance = meters
  end
  
  def from_mins_mile(mins, secs)
    mins = (mins or 0).abs.to_i
    secs = (secs or 0).abs.to_i
    @distance = 1609.344
    @seconds = (mins * 60) + secs
    to_meters_sec
  end
  
  def from_miles_hour(miles)
    miles = (miles or 0).abs
    @distance = miles * 1609.344
    @seconds = 3600
    to_meters_sec
  end
  
  def from_mins_km(mins, secs)
    mins = (mins or 0).abs.to_i
    secs = (secs or 0).abs.to_i
    @distance = 1000.0
    @seconds = (mins * 60) + secs
    to_meters_sec
  end
  
  def from_kms_hour(kms)
    kms = (kms or 0).abs
    @distance = kms * 1000.0
    @seconds = 3600
    to_meters_sec
  end
  
  def from_meters_sec(meters)
    meters = (meters or 0).abs
    @distance = meters
    @seconds = 1
    end
  
  def to_mins_mile
    (26.8224 / (@distance / @seconds)).round(3)
  end
  
  def to_miles_hour 
    ((@distance / @seconds) * 2.23694).round(3)
  end
  
  def to_mins_km
    (16.667 / (@distance / @seconds)).round(3)
  end
  
  def to_kms_hour
    ((@distance / @seconds) * 3.6).round(3)
  end
  
  def to_meters_sec
    if @seconds != 0 
      ((@distance / @seconds)).round(3)
    else
      0.0
    end      
  end  
end
